package com.totoro.dubbo.dubbo_invok;

import com.alibaba.dubbo.config.ApplicationConfig;
import com.alibaba.dubbo.config.ProtocolConfig;
import com.alibaba.dubbo.config.ReferenceConfig;
import com.alibaba.dubbo.config.RegistryConfig;
import com.alibaba.dubbo.rpc.service.GenericService;
import com.fenqile.tql.business.response.botao.BusinessInfoDto;
import com.fenqile.tql.business.service.botao.BusinessInfoService;

/**
 * dubbo泛化调用
 * Created by Niki on 2018/9/21 10:30
 */
public class Invok {
    private static void invok() {
        ApplicationConfig application = new ApplicationConfig();
        application.setName("dubbo_invok");

        RegistryConfig registry = new RegistryConfig();
        registry.setAddress("zookeeper://10.1.48.179:2182?backup=10.1.50.103:2182,10.1.50.144:2182");

        ReferenceConfig<BusinessInfoService> reference = new ReferenceConfig<>();
        reference.setApplication(application);
//        reference.setRegistry(registry);
        reference.setUrl("10.1.13.34:30506");

        reference.setInterface(BusinessInfoService.class);
        reference.setVersion("2.0.0");
        reference.setGroup("default");
        reference.setProtocol("fsof");
        reference.setTimeout(5000);
        reference.setCheck(false);

        BusinessInfoService businessInfoService = reference.get();
        BusinessInfoDto dto = businessInfoService.queryBusinessInfoByBusinessId("QDC201804250002016");
        System.out.println(dto.toString());
//        Object object = service.$invoke("queryBusinessInfoByBusinessId", new String[]{String.class.getName()}, new Object[]{"QDC201804250002016"});
//        System.out.println(object.toString());
    }

    public static void main(String[] args) {
        invok();
    }
}
